<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>导航栏</title>
    <!-- <link rel="stylesheet" href="./index.css"> -->
    <link
      href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.0/css/all.min.css"
      rel="stylesheet"
    />
    <style>
      *{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }

      body{
        cursor: crosshair;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
        background: linear-gradient(200deg,#a8edea,#fed6e3);
      }
      
      .wrappar{
        width: 60vw;
        height: 60px;
        line-height: 60px;
        background-color: #ffffff;
        box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.25);
        border-radius: 50px ;
      } 
      
      .wrappar nav{
        display: flex;
        position: relative;
      }
      
      .wrappar nav label{
        flex: 1;
        width: 100%;
        position: relative;
        z-index: 1;
        cursor: crosshair;
      }

      
      .wrappar nav label a{
        position: relative;
        z-index: -1;
        color: #333;
        font-size: 20px;
        font-weight: 500;
        text-decoration: none;
      }
      .wrappar nav label a i{
        font-size: 25px;
        margin: 0 7px;
      }
      .wrappar nav input{
        display: none;
      }
      .wrappar nav .tab{
        position: absolute;
        height: 100%;
        width: 20%;
        left: 0;
        bottom: 0;
        background: linear-gradient(to right, #f09819,#ff5858);
        border-radius: 50px;
        transition: 0.6s cubic-bezier(0.68,-0.55,0.265,1.55); 
         transition: 0.6s
      }
      .wrappar nav #home:checked ~ label.home a,
      .wrappar nav #comment:checked ~ label.comment a,
      .wrappar nav #envelope:checked ~ label.envelope a,
      .wrappar nav #heart:checked ~ label.heart a,
      .wrappar nav #user:checked ~ label.user a{
        color: #fff;
        transition: 0.6s;
      }

      .wrappar nav #comment:checked ~ .tab{
        left: 20%;
      }
      .wrappar nav #envelope:checked ~ .tab{
        left: 40%;
      }
      .wrappar nav #heart:checked ~ .tab{
        left: 60%;
      }
      .wrappar nav #user:checked ~ .tab{
        left: 80%;
      } 
    </style>
  </head>
  <body>
    <div class="wrappar">
      <nav>
        <input type="radio" name="tab" id="home" checked />
        <input type="radio" name="tab" id="comment" />
        <input type="radio" name="tab" id="envelope" />
        <input type="radio" name="tab" id="heart" />
        <input type="radio" name="tab" id="user" />

        <label for="home" class="home">
          <a href="#">
            <i class="fa fa-home" aria-hidden="true"></i>
            Home
          </a>
        </label>
        <label for="comment" class="comment">
          <a href="#">
            <i class="fa fa-comment" aria-hidden="true"></i>
            Comment
          </a>
        </label>
        <label for="envelope" class="envelope">
          <a href="#">
            <i class="fa fa-envelope" aria-hidden="true"></i>
            Envelope
          </a>
        </label>
        <label for="heart" class="heart">
          <a href="#">
            <i class="fa fa-heart" aria-hidden="true"></i>
            Heart
          </a>
        </label>
        <label for="user" class="user">
          <a href="#">
            <i class="fa fa-user" aria-hidden="true"></i>
            User
          </a>
        </label>
        <div class="tab"></div>
      </nav>
    </div>
  </body>
</html>
